import { Http } from "../http/http"

class UserModel {
  /**
   *  小程序登录
   */
  static async appletLogin(openid){
    return await Http.request({
        url: `app/loginByApplet?openid=${openid}`,
        method:'GET',
    })
  }
  
  // 手机密码登录
  static async phoneLogin(phone, pwd){
    return await Http.request({
        url: `app/loginByPassword?phone=${phone}&pwd=${pwd}`,
        method:'GET',
    })
  }

  // 手机验证码 + 密码注册
  static async phoneReg(data){
    return await Http.request({
        url: `app/registerByPassword`,
        method:'POST',
        data:data
    })
  }
  // 退出登录
  static async logout(){
    return await Http.request({
        url: `app/logout`,
        method:'GET',
    })
  }

  // 获取用户微信手机号
  static async getPhone(data){
    return await Http.request({
        url: `app/decryptPhone`,
        method:'Post',
        data:data
    })
  }

  /**
   *  小程序登录
   * @Deprecated
   */
  static async login(code){
    return await Http.request({
        url: `app/loginApplet/${code}`,
        method:'GET',
    })
  }

  // 登录用户 获取用户信息
  static async getUser(data){
    return await Http.request({
        url: `app/user`,
        method:'GET'
    })
  }

  // 更新用户信息
  static async editUser(data){
    return await Http.request({
        url: `app/user`,
        method:'PUT',
        data:data
    })
  }

  // 更新密码
  static async editPwd(pwd){
    return await Http.request({
        url: `app/modifyPassWord?pwd=${pwd}`,
        method:'POST'
    })
  }

  // 获取短信
  static async sms(phone){
    return await Http.request({
        url: `app/sms/send?phone=${phone}`
    })
  }

  // 新闻点赞列表
  static async newsDigList(){
    return await Http.request({
        url: `system/users/center/news`
    })
  }

  // 资料点赞
  static async digData(data){
    return await Http.request({
        url: `system/data/digData`,
        method:'POST',
        data:data
    })
  }

  // 资料点赞列表
  static async dataDigList(){
    return await Http.request({
        url: `system/users/center/data`
    })
  }

  // 视频点赞
  static async digCourse(data){
    return await Http.request({
        url: `system/course/digCourse`,
        method:'POST',
        data:data
    })
  }

  // 视频点赞列表
  static async courseDigList(){
    return await Http.request({
        url: `system/users/center/course`
    })
  }

  // 两新组织点赞
  static async digTwoNew(data){
    return await Http.request({
        url: `system/organization/digTwoNew`,
        method:'POST',
        data:data
    })
  }

  // 两新组织收藏列表
  static async twoNewDigList(){
    return await Http.request({
        url: `system/users/center/collect`
    })
  }

  // 组织生活-风采展示 点赞
  static async digBeauty(data){
    return await Http.request({
        url: `system/beauty/digBeauty`,
        method:'POST',
        data:data
    })
  }

  // 组织生活-风采展示 点赞列表
  static async beautyDigList(){
    return await Http.request({
        url: `system/users/center/beauty`
    })
  }

  // 用户答题记录
  static async userAnswerList(){
    return await Http.request({
        url: `system/answer/app/list`
    })
  }

  // 用户党建活动列表
  static async userPartyList(stateCode){
    return await Http.request({
        url: `system/wish/userPartyActivity/${stateCode}`,
        method:'GET'
    })
  }

  // 用户心愿列表
  static async userWishList(stateCode){
     return await Http.request({
         url: `system/wish/userWishActivity/${stateCode}`,
        method:'GET'
    })
  }

  // 用户取消报名
  static async userCancelParty(data){
    return await Http.request({
        url: `system/wish/applyPartyActivity`,
        method:'POST',
        data:data
    })
  }

  // 更新用户播放记录
  static async userUpdateWatch(data){
    return await Http.request({
        url: `system/course/app/watch`,
        method:'POST',
        data:data
    })
  }

}

export {
  UserModel
}